#!/usr/bin/python
# -*- coding:utf-8 -*-

import arrow

from app.db.models.balances import Balances


def check_api_module(uid):
    """查询用户购买的api是否可用"""
    balance = Balances.objects.filter(uid=uid).first()
    if not balance:
        return False
    api_exp_time = balance.balance.api.time
    if (not api_exp_time) or int(api_exp_time) < arrow.now().timestamp():
        return False
    return int(api_exp_time)
